require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'shoulda/tasks'
begin
  require 'rcov/rcovtask'
rescue LoadError
  warn 'rcov not available.'
end

begin
  require 'jeweler'
  Jeweler::Tasks.new do |s|
    s.name = "unfuddle_my_email"
    s.summary = %Q{Post emails from POP server as Unfuddle Tickets.}
    s.email = "matt@smajnr.net"
    s.homepage = "http://github.com/mhaley/unfuddle_my_email"
    s.description = "Post emails from POP server as Unfuddle Tickets."
    s.authors = ["Matt Haley"]
    s.files = FileList["README", "LICENSE", "VERSION.yml", "configuration-sample.yml", "{bin,lib,test}/**/*"]
    s.rubyforge_project = 'mhaley'

    s.add_dependency "mail", ">= 1.6.0"

    s.add_development_dependency "flexmock"
    s.add_development_dependency "shoulda"
  end

  Jeweler::RubyforgeTasks.new do |rubyforge|
    rubyforge.doc_task = "rdoc"
  end

  Jeweler::GemcutterTasks.new
rescue LoadError
  puts "Jewler not available."
end

Rake::TestTask.new do |t|
  t.libs << 'lib' 'test'
  t.pattern = 'test/**/*_test.rb'
  t.verbose = false
end

Rake::RDocTask.new do |rdoc|
  rdoc.rdoc_dir = 'rdoc'
  rdoc.title    = 'UnfuddleMyEmail'
  rdoc.options << '--line-numbers' << '--inline-source'
  rdoc.rdoc_files.include('README*')
  rdoc.rdoc_files.include('LICENSE*')
  rdoc.rdoc_files.include('lib/**/*.rb')
end

if defined?(Rcov)
  Rcov::RcovTask.new do |t|
    t.libs << 'lib' 'test'
    t.test_files = FileList['test/**/*_test.rb']
    t.verbose = true
  end
end

desc "Run UnfuddleMyEmail"
task :run, :configuration_file do |t, args|
  require 'unfuddle_my_email'
  configuration_file = args.configuration_file
  puts "Using configuration file: #{configuration_file}"
  runner = UnfuddleMyEmail::Runner.new(configuration_file)
  runner.run
end

task :default => :test

